package com.zyy.api.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * @author zhangyangyang
 * @createTime 2023414 16:38
 * @description 标签加权水平
 */
@Getter
@AllArgsConstructor
public enum LabelWeightLevel {

    //最大值最小值前开后闭[0, 0.2)
    UNKNOWN(0, 0, 0),
    LEVEL_ONE(1, 0, 0.2),
    LEVEL_TWO(2, 0.2, 0.4),
    LEVEL_THREE(3, 0.4, 0.6),
    LEVEL_FOUR(4, 0.6, 0.8),
    LEVEL_FIVE(5, 0.8, 1);

    private int level;
    private double min;
    private double max;

    public static LabelWeightLevel convert(int level) {
        return Stream.of(values())
            .filter(labelWeightLevel -> labelWeightLevel.getLevel() == level)
            .findFirst()
            .orElse(UNKNOWN);
    }
}
